package com.instpower.things.handlers;

import com.instpower.things.config.Configs;
import com.instpower.things.instpower.Connection;
import com.instpower.things.instpower.Handler;
import com.instpower.things.transport.DataBuffer;
import com.instpower.things.transport.Request;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

/**
 * @ClassName Handler0008Action
 * @Author: hellmash@gmail.com
 * @Date: 2020/3/24
 * @Version: 1.0.0
 * @Description: 协议参数暂无处理
 */
@Component(value = "CMD0008")
public class Handler0008Action extends Handler<Request> {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public short getId() {
        return Configs.PROTO_ARGS;
    }

    @Override
    public void execute(Connection connection, Request request) throws UnsupportedEncodingException {
        String sn = "";
        if( request!=null && request.getHeader()!=null){
           sn =  request.getHeader().getAddr();
        }
        logger.info("[{}]:Exec - CMD0008 - BEGIN",sn);
        DataBuffer buffer = request.getData().encode();
        short bear            = buffer.readShort();
        short retryTime       = buffer.readShort();
        byte retry          = buffer.readByte();

        // release after read
        buffer.release();

        logger.info("[{}]:Exec - CMD0008 - END",sn);
    }
}
